﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class BBox : OdGeBoundBlock3d, OdSiShape
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public BBox(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.BBox_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(BBox obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~BBox()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_BBox(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		HandleRef OdSiShape.GetCPtr()
		{
			return new HandleRef(this, GlobalsPINVOKE.BBox_OdSiShape_GetCPtr(this.swigCPtr.Handle));
		}

		public static BBox.ExtentsType explodeExtent(OdGePoint3d points, OdGeExtents3d extents)
		{
			BBox.ExtentsType result = (BBox.ExtentsType)GlobalsPINVOKE.BBox_explodeExtent__SWIG_0(OdGePoint3d.getCPtr(points), OdGeExtents3d.getCPtr(extents));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static BBox.ExtentsType explodeExtent(OdGePoint3d points, OdGeBoundBlock3d extents)
		{
			BBox.ExtentsType result = (BBox.ExtentsType)GlobalsPINVOKE.BBox_explodeExtent__SWIG_1(OdGePoint3d.getCPtr(points), OdGeBoundBlock3d.getCPtr(extents));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool contains(OdGeExtents3d extents, bool planar, OdGeTol tol)
		{
			bool result = GlobalsPINVOKE.BBox_contains(this.swigCPtr, OdGeExtents3d.getCPtr(extents), planar, OdGeTol.getCPtr(tol));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool intersects(OdGeExtents3d extents, bool planar, OdGeTol tol)
		{
			bool result = GlobalsPINVOKE.BBox_intersects(this.swigCPtr, OdGeExtents3d.getCPtr(extents), planar, OdGeTol.getCPtr(tol));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdSiShape clone()
		{
			OdSiShapeImpl result = new OdSiShapeImpl(GlobalsPINVOKE.BBox_clone(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void transform(OdGeMatrix3d mtx)
		{
			GlobalsPINVOKE.BBox_transform(this.swigCPtr, OdGeMatrix3d.getCPtr(mtx));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public BBox() : this(GlobalsPINVOKE.new_BBox__SWIG_0(), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public BBox(BBox source) : this(GlobalsPINVOKE.new_BBox__SWIG_1(BBox.getCPtr(source)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public BBox(OdGePoint3d arg0, OdGeVector3d side1, OdGeVector3d side2, OdGeVector3d side3) : this(GlobalsPINVOKE.new_BBox__SWIG_2(OdGePoint3d.getCPtr(arg0), OdGeVector3d.getCPtr(side1), OdGeVector3d.getCPtr(side2), OdGeVector3d.getCPtr(side3)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public BBox(OdGePoint3d p1, OdGePoint3d p2) : this(GlobalsPINVOKE.new_BBox__SWIG_3(OdGePoint3d.getCPtr(p1), OdGePoint3d.getCPtr(p2)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static OdSiShape kOverallSpace
		{
			get
			{
				OdSiShapeImpl result = new OdSiShapeImpl(GlobalsPINVOKE.BBox_kOverallSpace_get(), false);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
		}

		public static OdSiShape kNoSpace
		{
			get
			{
				OdSiShapeImpl result = new OdSiShapeImpl(GlobalsPINVOKE.BBox_kNoSpace_get(), false);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		public enum ExtentsType
		{
			k2dExtents,
			k3dExtents
		}
	}
}
